import type { LoginCodeData } from '@/types/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const userStore = defineStore(
  'user',
  () => {
    const token = ref('')
    const user = ref({} as LoginCodeData)
    const clearToken = () => {
      token.value = ''
    }
    return {
      token,
      clearToken,
      user,
    }
  },
  {
    unistorage: {
      paths: ['count', 'token', 'user'],
    },
  }
)
